var app = angular.module('skiApp', [
    'ngRoute',
    'ngTouch'
])
.config(function($routeProvider){
	
	$routeProvider
		// HOME PAGE
		.when('/', {
			templateUrl: 'app/components/home/homeView.html'
		})
		// PROGRAM PAGE
		.when('/program', {
			templateUrl: 'app/components/program/programView.html',
			controller: 'programController'
		})
		// EAT & DRINK PAGE
		.when('/foods', {
			templateUrl: 'app/components/foods/foodsView.html',
			controller: 'foodsController'
		})
                // EAT & DRINK - FOOD PLACES
		.when('/foods/:id', {
			templateUrl: 'app/components/foods/foodView.html',
			controller: 'foodController'
		})
		// SOCIAL MEDIA PAGE
		.when('/some', {
			templateUrl: 'app/components/some/someView.html',
			controller: 'someController'
		})
		// FAVORITES PAGE
                .when('/favorites', {
                        templateUrl: 'app/components/favorites/favoritesView.html',
                        controller: 'favController'
                })
		// INFO PAGE
		.when('/info', {
			templateUrl: 'app/components/info/infoView.html'
		})
		// TICKETS PAGE
		.when('/info/tickets', {
			templateUrl: 'app/components/info/tickets/ticketsView.html'
		})
		// INFO PAGES
		.when('/info/:page', {
			templateUrl: 'app/components/info/infoPageView.html',
                        controller: 'infoController'
		})
                // EVENT PAGES
                .when('/events', {
                        templateUrl: 'app/components/events/eventsView.html',
                        controller: 'eventsController'
                })
                .when('/events/:category/:detail', {
                        templateUrl: 'app/components/events/detailView.html',
                        controller: 'detailController'
                })
                .when('/events/:id', {
                        templateUrl: 'app/components/events/eventView.html',
                        controller: 'eventController'
                })
		
		.otherwise({
			redirectTo: '/'
		});
		
})
.controller('appController', ['$scope', '$location', 'storageService', function($scope, $location, storageService) {
        // check if first run
        storageService.firstRun();
        
        // all below handle the swiping and menu toggling
        $scope.$on('$locationChangeStart', function(){
            $scope.menuClassVar = "";
        });

	$scope.toggleMenu = function(){
            if($scope.menuClassVar === "active"){
                $scope.menuClassVar = "";
            } else {
                $scope.menuClassVar = "active";
            }
	};
        $scope.swipeRight = function (){
            // Disable swiping out the menu in program page
            if($location.path() !== "/program"){
                $scope.menuClassVar = "active";
            }
        };
        $scope.swipeLeft = function(){
            // Disable swiping out the menu in program page
            if($location.path() !== "/program"){
                $scope.menuClassVar = "";
            }
        };
}]);
